﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Cart.aspx.cs" Inherits="HTComics.Web.Order.Cart" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    
    <link href="../Css/jquery-ui-1.8.18.custom.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(doOnLoad);

        function doOnLoad() {
            $('button[att|="rem"]').each(function (index, value) {
                $(this).button().click(function () {
                    remove(value.cid, value.issue, value.condId);
                });
            });

            $('#btnRemoveAll').button().click(remove);

            $('#btnOrder').button().click(function () {
                var sure;
                sure = window.confirm("Are you sure you want to place the order?");
                if (sure) {
                    window.location = "SubmitOrder.aspx";
                }

                return false;
            });
        }

        function remove(cid, issue, condId) {
            var sure;
            if (issue == undefined && condId == undefined)
                sure = window.confirm("Are you sure you to remove all the item(s) Cart?");
            else
                sure = window.confirm("Are you sure you to remove the item from Cart?");

            if (sure) {
                if (issue == undefined && condId == undefined)
                    updateCart("", "", "", "xx");
                else
                    updateCart(cid, issue, condId, "x");

                loc = window.location.toString();
                loc = loc.replace("#", "");
                if (loc.search("=") != -1)
                    loc = loc.substring(0, loc.search("=") - 2);
                loc += "?i=" + new Date().getTime();

                window.location.replace(loc);
            }
            return false;               
        }

        function showDetails(img) {
            if (typeof (img) == "string")
                img = $("#img" + img);
            //img = document.getElementById("img" + img);
            else
                img = $(img);

            var html;
            $("#divImage").empty();
            $("#divImage").dialog("destroy");

            html = "<table>";
            html += "<tr>";
            html += "<td><img src=\"../Images/Covers/" + img.attr("cn").substring(0, 1) + "/" + img.attr("cn") + "/" + img.attr("issue") + ".jpg\" Height='400px' Width='300px' /></td>";

            html += "<td><table width='400px' cellspacing='10'>"
            html += "<tr><td><b>Comic:</b></td><td>" + img.attr("cn") + "</td></tr>"
            html += "<tr><td><b>Issue:</b></td><td>" + img.attr("issue") + "</td></tr>"
            html += "<tr><td><b>Cover Date:</b></td><td>" + img.attr("cd") + "</td></tr>"
            html += "<tr><td><b>Cover Price:</b></td><td>€" + img.attr("cp") + "</td></tr>"
            html += "<tr><td><b>Storylines:</b></td><td>" + img.attr("sl") + "</td></tr>"
            html += "<tr><td><b>Writer:</b></td><td>" + img.attr("wrt") + "</td></tr>"
            html += "<tr><td><b>Artist:</b></td><td>" + img.attr("art") + "</td></tr>"
            html += "</table></td>"
            html += "</tr>";

            html += "</table>";

            $("#divImage").append(html);
            $("#divImage").dialog({
                title: "Issue Details",
                modal: true,
                height: 'auto',
                width: 'auto',
                position: ['center', 'middle']
            });
        }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Heading" runat="server">
    Shopping Cart
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<%=tblCart%>

    <div id="divImage">        
    </div>
</asp:Content>
